#include "Mesh.h"
#include <sfml/Graphics.hpp>

Mesh::Mesh(void) : mColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}

Mesh::~Mesh(void)
{
}

void Mesh::Render()
{
	if (!mVertexBuffer || !mIndexBuffer) {
		return;
	}

	glColor3fv(mColor.Ptr());
	for (size_t i = 0; i + 2 < mIndexBuffer->size(); i += 3)
	{
		glBegin(GL_TRIANGLES);
		for (size_t j = i; j < i + 3; j++)
		{
			Vertex& v = (*mVertexBuffer)[(*mIndexBuffer)[j]];
			glVertex3fv(v.position.Ptr());
		}
		glEnd();
	}
	
	/*
	glColor3fv(mColor.Ptr());
	for (size_t i = 0; i + 2 < mVertexBuffer.size(); i += 3)
	{
		glBegin(GL_TRIANGLES);
		for (size_t j = i; j < i + 3; j++)
		{
			Vertex& v = mVertexBuffer[j];
			glVertex3fv(v.position.Ptr());
		}
		glEnd();
	}
	*/
}
